package com.bzframework.pro.enums;

import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;

/**
 * @Author bingzhong
 * @Date 2025/4/11 11:35
 * @Description 有效性判定
 */
@Getter
@RequiredArgsConstructor
public enum EffectivenessEnum {


    /**
     * 无效
     */
    invalid("0","有效"),

    /**
     * 有效
     */
    effective("1","无效"),

    /**
     * 待定
     */
    undetermined("2", "待定"),

    all("-1", "全部");

    private final String code;

    private final String name;

    public static EffectivenessEnum of(String code) {
        if (StringUtils.isEmpty(code)) {
            return EffectivenessEnum.undetermined;
        }
        for (EffectivenessEnum effectivenessEnum : EffectivenessEnum.values()) {
            if (effectivenessEnum.getCode().equals(code)) {
                return effectivenessEnum;
            }
        }
        return null;

    }


}
